
import org.apache.commons.beanutils.PropertyUtils;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.util.List;

@Service
public class DmsMachineDeployTemplateServiceImpl implements DmsMachineDeployTemplateService  {

    @Resource
    private DmsMachineDeployTemplateMapper dmsMachineDeployTemplateMapper;

    /**
     * 获取 DmsMachineDeployTemplate 分页列表
     */
    @Transactional
    public IPage getDmsMachineDeployTemplatePagination( PaginationVo paginationVo, DmsMachineDeployTemplateQuery dmsMachineDeployTemplateQuery ) throws Exception {

        IPage page = new Page( paginationVo.getPageIndex(), paginationVo.getPageSize() );
        LambdaQueryWrapper<DmsMachineDeployTemplateEntity> lqs = new LambdaQueryWrapper();
        dmsMachineDeployTemplateMapper.selectPage(page, lqs);

        List<DmsMachineDeployTemplateEntity> record = page.getRecords();
        if( !ObjectUtil.isNotEmptyList(record)){
            return page;
        }
        return null;
    }


    /**
     * 获取 DmsMachineDeployTemplate 所有数据
     *
    */
    @Transactional
    public List<DmsMachineDeployTemplateEntity> getDmsMachineDeployTemplateAllList( DmsMachineDeployTemplateQuery dmsMachineDeployTemplateQuery ) throws Exception {

        LambdaQueryWrapper<DmsMachineDeployTemplateEntity> lqs = new LambdaQueryWrapper();
        List<DmsMachineDeployTemplateEntity> list = dmsMachineDeployTemplateMapper.selectList(lqs);
        return list;
    }


    /**
     * 获取 DmsMachineDeployTemplate 详情
    */
    @Transactional
    public DmsMachineDeployTemplateEntity getDmsMachineDeployTemplateDetail( Long id) throws Exception {

        DmsMachineDeployTemplateEntity dmsMachineDeployTemplate = dmsMachineDeployTemplateMapper.selectById(id);
        return dmsMachineDeployTemplate;
    }


    /**
     * 新增 DmsMachineDeployTemplate
     * */
    @Transactional
    public void addDmsMachineDeployTemplate(DmsMachineDeployTemplateVo dmsMachineDeployTemplateVo) throws Exception {

        DmsMachineDeployTemplateEntity dmsMachineDeployTemplate = new DmsMachineDeployTemplateEntity();
        ReflectionCopy.copyProperties( dmsMachineDeployTemplate, dmsMachineDeployTemplateVo );
        dmsMachineDeployTemplateMapper.insert(dmsMachineDeployTemplate);
        return;
    }


    /**
     * 更新 DmsMachineDeployTemplate
     * */
    @Transactional
    public void updateDmsMachineDeployTemplate( DmsMachineDeployTemplateVo dmsMachineDeployTemplateVo) throws Exception {

        if( dmsMachineDeployTemplateVo.getId() == null ){
            throw GlobalException.gen(10021, "id不存在");
        }
        DmsMachineDeployTemplateEntity dmsMachineDeployTemplate = new DmsMachineDeployTemplateEntity();
        ReflectionCopy.copyProperties( dmsMachineDeployTemplate, dmsMachineDeployTemplateVo );
        dmsMachineDeployTemplateMapper.updateById(dmsMachineDeployTemplate);
        return;
    }

    /**
     * 删除 DmsMachineDeployTemplate
     * */
    @Transactional
    public void batchRemoveDmsMachineDeployTemplate( List<Long> ids ) throws Exception {


        if( !ObjectUtil.isNotEmptyList(ids) ){
            throw GlobalException.gen(10011, "要删除的id不存在");
        }
        dmsMachineDeployTemplateMapper.deleteBatchIds(ids);
    }

}

      